package com.ruoyi.archives.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.archives.domain.SysArchivessystem;
import com.ruoyi.archives.service.ISysArchivessystemService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 档案管理Controller
 * 
 * @author gzhankh
 * @date 2022-02-26
 */
@Api("学生档案管理接口")
@RestController
@RequestMapping("/archives/archivessystem")
public class SysArchivessystemController extends BaseController
{
    @Autowired
    private ISysArchivessystemService sysArchivessystemService;

    /**
     * 查询档案管理列表
     */
    @ApiOperation("获取学生档案列表")
    @PreAuthorize("@ss.hasPermi('archives:archivessystem:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysArchivessystem sysArchivessystem)
    {
        startPage();
        List<SysArchivessystem> list = sysArchivessystemService.selectSysArchivessystemList(sysArchivessystem);
        return getDataTable(list);
    }

    @ApiOperation("获取学生档案列表无权限")
    @GetMapping("/listNumber")
    public TableDataInfo listNumber(SysArchivessystem sysArchivessystem)
    {
        startPage();
        List<SysArchivessystem> list = sysArchivessystemService.selectList(sysArchivessystem);
        return getDataTable(list);
    }

    /**
     * 导出档案管理列表
     */
    @ApiOperation("档案管理导出excel")
    @PreAuthorize("@ss.hasPermi('archives:archivessystem:export')")
    @Log(title = "档案管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysArchivessystem sysArchivessystem)
    {
        List<SysArchivessystem> list = sysArchivessystemService.selectSysArchivessystemList(sysArchivessystem);
        ExcelUtil<SysArchivessystem> util = new ExcelUtil<SysArchivessystem>(SysArchivessystem.class);
        util.exportExcel(response, list, "档案管理数据");
    }

    /**
     * 获取档案管理详细信息
     */
    @ApiOperation("获取档案管理详细信息")
    @PreAuthorize("@ss.hasPermi('archives:archivessystem:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(sysArchivessystemService.selectSysArchivessystemById(id));
    }

    /**
     * 新增档案管理
     */
    @ApiOperation("新增档案管理")
    @PreAuthorize("@ss.hasPermi('archives:archivessystem:add')")
    @Log(title = "档案管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysArchivessystem sysArchivessystem)
    {
        return toAjax(sysArchivessystemService.insertSysArchivessystem(sysArchivessystem));
    }

    /**
     * 修改档案管理
     */
    @ApiOperation("修改档案管理")
    @PreAuthorize("@ss.hasPermi('archives:archivessystem:edit')")
    @Log(title = "档案管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysArchivessystem sysArchivessystem)
    {
        return toAjax(sysArchivessystemService.updateSysArchivessystem(sysArchivessystem));
    }

    /**
     * 删除档案管理
     */
    @ApiOperation("删除档案管理")
    @PreAuthorize("@ss.hasPermi('archives:archivessystem:remove')")
    @Log(title = "档案管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysArchivessystemService.deleteSysArchivessystemByIds(ids));
    }
}
